diff options
| author | Adam Soltys <[email protected]> | 2025-07-19 17:59:56 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2025-07-19 18:07:57 -0700 |
| commit | d87ecae6ee46af4790e1f57cd5d82a35ab29e646 (patch) | |
| tree | 5fa86b7b8902315f625eca493861f3ad97de5a5c /src/routes/(app)/invoice/[id]/+layout.server.ts | |
| parent | fea147df07046f240e77075e7c743959d85b1271 (diff) | |
| download | coinos-ui-d87ecae6ee46af4790e1f57cd5d82a35ab29e646.tar.gz coinos-ui-d87ecae6ee46af4790e1f57cd5d82a35ab29e646.zip | |
prompt for tip for auto pays
Diffstat (limited to 'src/routes/(app)/invoice/[id]/+layout.server.ts')
| -rw-r--r-- | src/routes/(app)/invoice/[id]/+layout.server.ts | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/src/routes/(app)/invoice/[id]/+layout.server.ts b/src/routes/(app)/invoice/[id]/+layout.server.ts index 590e5d4d..d6ab979e 100644 --- a/src/routes/(app)/invoice/[id]/+layout.server.ts +++ b/src/routes/(app)/invoice/[id]/+layout.server.ts @@ -12,25 +12,29 @@ export async function load({ cookies, depends, params, url, parent }) { if (id) { invoice = await get(`/invoice/${id}`); const options = !!url.searchParams.get("options"); - - if ( - user && - invoice.uid !== user.id && - !(url.pathname.includes("tip") || url.pathname.includes("memo")) && - !options - ) { - redirect(307, `/send/invoice/${id}`); - } - let { amount, pending, received } = invoice; amount = parseInt(amount); - subject = invoice.user; const paid = (!amount && (pending || received)) || (amount > 0 && (pending >= amount || received >= amount)); if (paid && !url.pathname.endsWith("paid")) { - redirect(307, `/invoice/${id}/paid` + (options ? "?options=true" : "")); + if (invoice.uid === user.id) + redirect(307, `/invoice/${id}/paid` + (options ? "?options=true" : "")); + else redirect(307, `/pay/${subject.username}/${invoice.amount}`); + } + + subject = invoice.user; + + if ( + user && + invoice.uid !== user.id && + !(url.pathname.includes("tip") || url.pathname.includes("memo")) && + !options + ) { + if (invoice.prompt && invoice.tip === null) + redirect(307, `/invoice/${id}/tip`); + else redirect(307, `/send/invoice/${id}`); } } |
